<template>
	<view class="root">
		<view class="body">
			<view class="">
				<text style="color: #DD514C;">带 * 号为必选 |必填项</text>
			</view>
			<view class="">
				<text style="color: #DD514C;">以下带 $ 的选项应附上证明材料</text>
			</view>
			<uni-forms ref="form" :rules="rules" :value="formData">

				<uni-group title="家庭经济困难信息(证明)">

					<u-checkbox-group @change="checkboxGroupChange" :wrap="true">
						<u-checkbox label-size="35" style="margin-top: 10rpx;color: #000000;" @change="checkboxChange"
							v-model="item.checked" v-for="(item, index) in typeList" :key="index" :name="item.name"
							:disabled="item.disabled">{{item.name}}</u-checkbox>
					</u-checkbox-group>
					<uni-forms-item v-if="brcj" label="学生残疾等级" name="stuLevel" labelWidth="200" labelPosition="top"
						required>
						<uni-data-picker v-model="formData.stuLevel" :localdata="Dis"
							popup-title="请选择学生残疾等级"></uni-data-picker>
					</uni-forms-item>

					<!-- <uni-forms-item v-if="jtzs" label="家庭遭受疫情" name="jtzsInfo" labelWidth="200" labelPosition="top"
						required>
						<uni-easyinput maxlength="100" v-model="formData.jtzsInfo" type="textarea"
							placeholder="不能含有特殊符号且长度不能超过100个字符"></uni-easyinput>
						<text style="float: right;">{{formData.jtzsInfo?formData.jtzsInfo.length : 0}}/100</text>
					</uni-forms-item> -->

					<uni-forms-item v-if="other" label="其他" name="other" labelWidth="200" labelPosition="top" required>
						<uni-easyinput maxlength="100" v-model="formData.other" type="textarea"
							placeholder="相关证件或手写相关情况描述（需含申请人签名和所在居委会或村委会联系电话）,不能含有特殊符号且长度不能超过100个字符"></uni-easyinput>
					</uni-forms-item>
				</uni-group>

				<uni-group title="" margin-top="">

					<uni-forms-item label="赡养老人($)" name="support" labelWidth="200" labelPosition="top">
						<uni-data-picker v-model="formData.support" :localdata="supportOp"
							popup-title="请选择赡养老人"></uni-data-picker>
					</uni-forms-item>

					<uni-forms-item label="家庭在学人数($)" required name="learns" labelWidth="200" labelPosition="top">
						<uni-data-picker v-model="formData.learns" :localdata="learns"
							popup-title="请选择家庭在学人数"></uni-data-picker>
					</uni-forms-item>

					<uni-forms-item label="父母从业情况($)" name="parEp" labelWidth="200" labelPosition="top">
						<uni-data-picker v-model="formData.parEp" :localdata="parEp"
							popup-title="请选择父母从业情况"></uni-data-picker>
					</uni-forms-item>

					<uni-forms-item label="父母文化($)" name="parCul" labelWidth="200" labelPosition="top">
						<uni-data-picker v-model="formData.parCul" :localdata="parCul"
							popup-title="请选择父母文化"></uni-data-picker>
					</uni-forms-item>

					<uni-forms-item label="父母年龄($)" name="parAge" labelWidth="200" labelPosition="top">
						<uni-data-picker v-model="formData.parAge" :localdata="parAge"
							popup-title="请选择父母年龄"></uni-data-picker>
					</uni-forms-item>

					<uni-forms-item label="学生本人或家庭成员是否患重大疾病($)" name="xsbrhj" labelWidth="300" labelPosition="top">
						<uni-data-picker v-model="formData.xsbrhj" :localdata="xsbrhj"
							popup-title="请选择"></uni-data-picker>
					</uni-forms-item>

					<!-- <uni-forms-item label="其他家庭成员（不含学生本人）是否患重大疾病（不含残疾）($)" labelWidth="300" labelPosition="top"
						name="otherFamilyMem">
						<uni-data-checkbox v-model="formData.otherFamilyMem" :localdata="logic" />
					</uni-forms-item -->


					<uni-forms-item label="父亲为残疾人($)" name="facj" labelWidth="200" labelPosition="top">
						<uni-data-checkbox @change="dc" v-model="formData.facj" :localdata="logic" />
					</uni-forms-item>

					<uni-forms-item v-if="disabledChildren" label="父亲残疾等级" name="faLevel" labelWidth="200"
						labelPosition="top" required>
						<uni-data-picker v-model="formData.faLevel" :localdata="Dis"
							popup-title="请选择父亲残疾等级"></uni-data-picker>
					</uni-forms-item>

					<uni-forms-item v-if="disabledChildren" label="父亲姓名" name="faName" labelWidth="200"
						labelPosition="top" required>
						<uni-easyinput v-model="formData.faName" type="text" placeholder=""></uni-easyinput>
					</uni-forms-item>

					<uni-forms-item v-if="disabledChildren" label="父亲身份证号码" name="faId" labelWidth="200"
						labelPosition="top" required>
						<uni-easyinput v-model="formData.faId" type="text" placeholder=""></uni-easyinput>
					</uni-forms-item>

					<uni-forms-item label="母亲为残疾人($)" name="mocj" labelWidth="200" labelPosition="top">
						<uni-data-checkbox @change="mocjChange" v-model="formData.mocj" :localdata="logic" />
					</uni-forms-item>

					<uni-forms-item v-if="mocj" label="母亲残疾等级" name="moLevel" labelWidth="200" labelPosition="top"
						required>
						<uni-data-picker v-model="formData.moLevel" :localdata="Dis"
							popup-title="请选择"></uni-data-picker>
					</uni-forms-item>

					<uni-forms-item v-if="mocj" label="母亲姓名" name="moName" labelWidth="200" labelPosition="top"
						required>
						<uni-easyinput v-model="formData.moName" type="text" placeholder=""></uni-easyinput>
					</uni-forms-item>

					<uni-forms-item v-if="mocj" label="母亲身份证号码" name="moId" labelWidth="200" labelPosition="top"
						required>
						<uni-easyinput v-model="formData.moId" type="text" placeholder=""></uni-easyinput>
					</uni-forms-item>


					<uni-forms-item label="家庭是否遭受重大自然灾害($)" name="naturalDisaster" labelWidth="200" labelPosition="top">
						<uni-data-checkbox @change="nd" v-model="formData.naturalDisaster" :localdata="logic" />
					</uni-forms-item>

					<uni-forms-item v-if="naturalDisaster" label="家庭遭受重大自然灾害时间" name="naturalDisasterTime"
						labelWidth="200" labelPosition="top" required>
						<uni-data-picker v-model="formData.naturalDisasterTime" :localdata="zrzhTime"
							popup-title="请选择"></uni-data-picker>
					</uni-forms-item>

					<uni-forms-item v-if="naturalDisaster" label="家庭遭受重大自然灾害描述" name="naturalDisasterInfo"
						labelWidth="200" labelPosition="top" required>
						<uni-easyinput v-model="formData.naturalDisasterInfo" type="textarea"
							placeholder="不能含有特殊符号且长度不能超过100个字符"></uni-easyinput>
						<text style="float: right;">{{formData.naturalDisasterInfo.length}}/100</text>
					</uni-forms-item>

					<uni-forms-item label="家庭是否遭受重大突发意外($s)" name="suddenAccident" labelWidth="200" labelPosition="top">
						<uni-data-checkbox @change="sa" v-model="formData.suddenAccident" :localdata="logic" />
					</uni-forms-item>

					<uni-forms-item v-if="suddenAccident" label="家庭遭重大突发意外时间" name="suddenAccidentTime" labelWidth="200"
						labelPosition="top" required>
						<uni-data-picker v-model="formData.suddenAccidentTime" :localdata="zdywTime"
							popup-title="请选择"></uni-data-picker>
					</uni-forms-item>

					<uni-forms-item v-if="suddenAccident" label="家庭遭受重大突发意外描述" name="suddenAccidentInfo"
						labelWidth="200" labelPosition="top" required>
						<uni-easyinput v-model="formData.suddenAccidentInfo" type="textarea"
							placeholder="不能含有特殊符号且长度不能超过100个字符"></uni-easyinput>
						<text style="float: right;">{{formData.suddenAccidentInfo.length}}/100</text>
					</uni-forms-item>


				</uni-group>

				<uni-group title="户籍信息">
					<u-checkbox-group :wrap="true">
						<u-checkbox @change="nchjChange" v-model="item.checked" v-for="(item, index) in huji"
							:key="index" :name="item.name">{{item.name}}</u-checkbox>
					</u-checkbox-group>
				</uni-group>

				<uni-group title="杂项">
					<uni-forms-item label="本人学费、住宿费" name="xuefei" labelWidth="200" labelPosition="top">
						<uni-data-picker v-model="formData.xuefei" :localdata="xuefeiOp"
							popup-title="请选择"></uni-data-picker>
					</uni-forms-item>

					<uni-forms-item label="家庭住房" name="familyHouse" labelWidth="200" labelPosition="top" required>
						<uni-data-picker v-model="formData.familyHouse" :localdata="familyHouseOp"
							popup-title="请选择"></uni-data-picker>
					</uni-forms-item>

					<uni-forms-item label="购车情况" name="buyVehicle" labelWidth="200" labelPosition="top" required>
						<uni-data-checkbox @change="buyVehicleChange" multiple v-model="formData.buyVehicle"
							:localdata="buyVehicleOp" />
					</uni-forms-item>

					<uni-forms-item label="家庭人口数" name="familyNum" labelWidth="200" labelPosition="top" required>
						<uni-easyinput v-model="formData.familyNum" type="text"
							placeholder="请输入不超过两位的数字	"></uni-easyinput>
					</uni-forms-item>

					<uni-forms-item label="家庭人均年收入" name="incomeAvg" labelWidth="200" labelPosition="top" required>
						<uni-easyinput v-model="formData.incomeAvg" type="text"
							placeholder="请输入不超过6位的数字"></uni-easyinput>
					</uni-forms-item>


					<uni-forms-item label="家庭欠债金额($)" name="debt" labelWidth="200" labelPosition="top">
						<uni-easyinput v-model="formData.debt" type="text" placeholder="请输入不超过8位的数字"></uni-easyinput>
					</uni-forms-item>

					<uni-forms-item v-if="debtRea" label="欠债原因" name="debtRea" labelWidth="200" labelPosition="top"
						required>
						<uni-easyinput maxlength="200" v-model="formData.debtRea" type="textarea"
							placeholder="不能含有特殊符号且长度不能超过200个字符"></uni-easyinput>
						<text style="float: right;">{{formData.debtRea.length}}/200</text>
					</uni-forms-item>

					<uni-forms-item label="请填写社区或村委的联系电话" name="comphone" labelWidth="200" labelPosition="top" required>
						<uni-easyinput type="number" placeholder="请填村委(可区号)联系方式"
							v-model="formData.comphone"></uni-easyinput>
					</uni-forms-item>



					<uni-forms-item label="请填写社区或村委的通信地址" name="community" labelWidth="200" labelPosition="top"
						required>
						<uni-easyinput type="text" placeholder="请输入" v-model="formData.community"></uni-easyinput>
					</uni-forms-item>

				</uni-group>

				<uni-group title="" margin-top="">
					<uni-forms-item label="家庭主要收入来源(只能八选一)" name="incomeType" labelWidth="200" labelPosition="top"
						required>
						<uni-data-checkbox @change="incomeTypeChange" :wrap="true" multiple
							v-model="formData.incomeType" :localdata="incomeType" />
					</uni-forms-item>
					<!-- <u-checkbox-group @change="checkboxGroupChange" :wrap="true">
										<u-checkbox label-size="25" style="margin-top: 4rpx;color: #000000;" @change="checkboxChange"
											v-model="item.checked" v-for="(item, index) in typeList1" :key="index" :name="item.name"
											:disabled="item.disabled">{{item.name}}</u-checkbox>
									</u-checkbox-group> -->
					<uni-forms-item v-if="incomeOther" label="其他应当计入家庭的收入" name="incomeOther" labelWidth="200"
						labelPosition="top" required>
						<uni-easyinput maxlength="50" v-model="formData.incomeOther" type="textarea"
							placeholder="若选择无收入请自动忽略(不能含有特殊符号且长度不能超过50个字符)"></uni-easyinput>
						<text style="float: right;">{{formData.incomeOther?formData.incomeOther.length : 0	}}/50</text>
					</uni-forms-item>
					<uni-forms-item label="已获得资助情况" name="yhzzInfo" labelWidth="200" labelPosition="top">
						<uni-easyinput maxlength="200" v-model="formData.yhzzInfo" type="textarea"
							placeholder="请填写获资助的（时间，受资助的具体项目，受资助的人民币）不能含有特殊符号且长度不能超过200个字符"></uni-easyinput>
						<text style="float: right;">{{formData.yhzzInfo?formData.yhzzInfo.length :0}}/200</text>
					</uni-forms-item>
				</uni-group>

				<!-- <uni-group title="证明材料上传" margin-top="">
					<text>请把图片命名后打包压缩上传</text>
					<uni-file-picker 
						v-model="file" 
						fileMediatype="all" 
						mode="list" 
						@select="select" 
						@progress="progress" 
						@success="success" 
						@fail="fail"
						@delete="del"
						limit="1"
					/>
				</uni-group> -->

				<uni-group title="" margin-top="">
					<uni-forms-item label="" name="">
						<button type="default" @click="submit">保存</button>
					</uni-forms-item>
				</uni-group>
			</uni-forms>
		</view>
	</view>
</template>

<script>
	import {
		addCatchInfo,
		getCatchInfo
	} from "@/api/catch.js"
	import {
		idNoValidator
	} from "@/utils/test.js"
	import {
		typeList
	} from "./data/catchData.js"
	var that; // 当前页面对象
	var vk; //vk依赖
	export default {
		data() {
			return {
				// 显示开关
				other: false,
				// jtzs: false,
				brcj: false,
				mocj: false,
				debtRea: false, //控制欠债原因
				incomeOther: false,
				formData: {
					stuLevel: '', //学生残疾等级
					// jtzsInfo: '', //家庭遭受疫情描述
					other: '', //其他
					parEp: '', //父母从业情况
					parCul: '', //父母文化
					parAge: '', //父母年龄
					support: '', //赡养老人
					learns: '', //在学人数
					// otherFamilyMem: '', //其他家庭成员是否患重大疾病
					xsbrhj: '', //学生本人或家庭成员是否患重大疾病
					facj: '', //父亲为残疾人
					faLevel: '', //父亲残疾等级
					faName: '', //父亲姓名
					faId: '', //父亲内地身份证号
					mocj: '', //母亲为残疾人
					moLevel: '', //母亲残疾等级
					moName: '', //母亲姓名
					moId: '', //母亲身份证号码
					naturalDisaster: '', //自然灾害
					naturalDisasterTime: '', //自然灾害时间
					naturalDisasterInfo: '', //自然灾害描述
					suddenAccident: '', //突发意外
					suddenAccidentTime: '', //突发意外时间
					suddenAccidentInfo: '', //突发意外描述
					xuefei: '', //学费、住宿费
					familyHouse: '', //家庭住房
					buyVehicle: [], //购车情况,
					familyNum: '', //家庭人口数,
					incomeAvg: '', //家庭人均年收入
					debt: '', //家庭欠债金额
					debtRea: '', //欠债原因
					incomeType: [], //家庭主要收入来源
					incomeOther: '', //其他收入
					yhzzInfo: '' //已获资助
				},

				// file:[],
				uploadOn: false,
				// 表单验证规则
				rules: {
					stuLevel: {
						rules: [{
							required: true,
							errorMessage: '请选择学生残疾等级'
						}]
					},
					// jtzsInfo: {
					// 	rules: [{
					// 		required: true,
					// 		errorMessage: '请填写家庭遭受疫情描述'
					// 	}, {
					// 		minLength: 1,
					// 		maxLength: 100,
					// 		errorMessage: '请填写家庭遭受疫情描述{minLength} 到 {maxLength} 个字符',
					// 	}, {
					// 		validateFunction: (rule, value, data, callback) => {
					// 			let reg = /^[\u4e00-\ue863a-z|A-Z|0-9（）(),，。.、]{1,100}$/
					// 			if (reg.test(value)) {
					// 				return true
					// 			} else {
					// 				callback('请填写家庭遭受疫情描述，不能含有特殊符号')
					// 			}
					// 		}
					// 	}]
					// },
					other: {
						rules: [{
							required: true,
							errorMessage: '请填写其他'
						}, {
							minLength: 1,
							maxLength: 100,
							errorMessage: '其他 {minLength} 到 {maxLength} 个字符',
						}, {
							validateFunction: (rule, value, data, callback) => {
								let reg = /^[\u4e00-\ue863a-z|A-Z|0-9（）(),，。.、]{1,100}$/
								if (reg.test(value)) {
									return true
								} else {
									callback('其他，不能含有特殊符号')
								}
							}
						}]
					},
					parEp: {
						rules: []
					},
					parCul: {
						rules: []
					},
					parAge: {
						rules: []
					},
					labors: {
						rules: [{
							required: true,
							errorMessage: '请输入劳动力人口'
						}]
					},
					learns: {
						rules: [{
							required: true,
							errorMessage: '请选择家庭在学人数'
						}]
					},
					// otherFamilyMem: {
					// 	rules: [{
					// 		requierd: true,
					// 		errorMessage: '请选择'
					// 	}]
					// },
					xsbrhj: {
						rules: [
							
						]
					},
					parUnemployment: {
						rules: [{
							required: true,
							errorMessage: '请选择'
						}]
					},
					//父亲残疾等级
					faLevel: {
						rules: [{
							required: true,
							errorMessage: '请选择父亲残疾等级'
						}]
					},
					//父亲姓名
					faName: {
						rules: [{
							required: true,
							errorMessage: '请填写父亲姓名'
						}, {
							validateFunction: (rule, value, data, callback) => {
								let reg = /^[\u4e00-\ue863·]{1,20}$/
								if (reg.test(value)) {
									return true
								} else {
									callback('父亲姓名,填写不正确！必须为汉字，长度大于1，不能超过20个字符，请检查')
								}
							}
						}]
					},
					//父亲内地身份证号
					faId: {
						rules: [{
								required: true,
								errorMessage: '父亲内地身份证号'
							},
							{
								validateFunction: (rule, value, data, callback) => {
									if (idNoValidator(value)) {
										return true
									} else {
										callback('父亲内地身份证号不正确')
									}
								}
							}
						]
					},
					moLevel: {
						rules: [{
							required: true,
							errorMessage: '请选择母亲残疾等级'
						}]
					},
					//母亲姓名
					moName: {
						rules: [{
							required: true,
							errorMessage: '请填写父亲姓名'
						}, {
							validateFunction: (rule, value, data, callback) => {
								let reg = /^[\u4e00-\ue863·]{1,20}$/
								if (reg.test(value)) {
									return true
								} else {
									callback('父亲姓名,填写不正确！必须为汉字，长度大于1，不能超过20个字符，请检查')
								}
							}
						}]
					},
					//母亲内地身份证号
					moId: {
						rules: [{
								required: true,
								errorMessage: '请填写母亲身份证号码'
							},
							{
								validateFunction: (rule, value, data, callback) => {
									if (idNoValidator(value)) {
										return true
									} else {
										callback('母亲内地身份证号不正确')
									}
								}
							}
						]
					},
					naturalDisaster: {
						rules: []
					},
					naturalDisasterTime: {
						rules: [{
							required: true,
							errorMessage: '请选择家庭遭受重大自然灾害时间'
						}]
					},
					naturalDisasterInfo: {
						rules: [{
								required: true,
								errorMessage: '请填写家庭遭受重大自然灾害描述'
							},
							{
								minLength: 1,
								maxLength: 100,
								errorMessage: '家庭遭受重大自然灾害描述{minLength} 到 {maxLength} 个字符',
							},
							{
								validateFunction: (rule, value, data, callback) => {
									let reg = /^[\u4e00-\ue863a-z|A-Z|0-9（）(),，。.、]{1,100}$/
									if (reg.test(value)) {
										return true
									} else {
										callback('家庭遭受重大自然灾害描述，不能含有特殊符号')
									}
								}
							}
						]
					},
					suddenAccident: {
						rules: []
					},
					suddenAccidentTime: {
						rules: [{
							required: true,
							errorMessage: '请选择家庭遭受重大突发意外时间'
						}]
					},
					suddenAccidentInfo: {
						rules: [{
								required: true,
								errorMessage: '请填写家庭遭受重大突发意外描述'
							},
							{
								minLength: 1,
								maxLength: 100,
								errorMessage: '家庭遭受重大突发意外描述{minLength} 到 {maxLength} 个字符',
							},
							{
								validateFunction: (rule, value, data, callback) => {
									let reg = /^[\u4e00-\ue863a-z|A-Z|0-9（）(),，。.、]{1,100}$/
									if (reg.test(value)) {
										return true
									} else {
										callback('家庭遭受重大突发意外描述，不能含有特殊符号')
									}
								}
							}
						]
					},
					buyVehicle: {
						rules: [{
							required: true,
							errorMessage: '请选择购车情况'
						}]
					},
					familyHouse: {
						rules: [{
							required: true,
							errorMessage: '请选择住房情况'
						}]
					},
					familyNum: {
						rules: [{
								required: true,
								errorMessage: '请填写家庭人口数'
							},
							{
								format: 'number',
								errorMessage: '家庭人口数必须为数字'
							}, {
								//异步校验
								validateFunction: function(rule, value, data, callback) {
									//不能为0

									if (String(value).length > 2) {
										callback('家庭人口数不超过2位')
									}
									return true
								}
							}
						]
					},
					incomeAvg: {
						rules: [{
								required: true,
								errorMessage: '请填写家庭人均年收入'
							},
							{
								format: 'number',
								errorMessage: '家庭人均年收入必须为数字'
							},
							{
								//异步校验
								validateFunction: function(rule, value, data, callback) {
									//不能为0
									value = Number(value)
									if (value == 0) {
										callback('人均年收入不能为0')
									} else if (value > 999999.99) {
										callback('整数位不超过6位,小数位不超过2位')
										//判断小数位
									} else if (!Number.isInteger(value)) {
										// console.log(typeof value)
										let str = String(value).split('.')
										if (str[1].length > 2) {
											callback('小数位不超过2位')
										}
									}
									return true
								}
							}
						]
					},
					debt: {
						rules: [{
							validateFunction: function(rule, value, data, callback) {
								//不能为0
								value = Number(value)
								if (value == 0) {
									callback('家庭欠债金额不能为0')
								} else if (value > 99999999.99) {
									callback('整数位不超过8位，小数位不超过2位')
									//判断小数位
								} else if (!Number.isInteger(value)) {
									let str = String(value).split('.')
									if (str[1].length > 2) {
										callback('小数位不超过2位')
									}
								}
								return true
							}
						}]
					},
					debtRea: {
						rules: [{
								required: true,
								errorMessage: '请填写欠债原因'
							},
							{
								minLength: 1,
								maxLength: 200,
								errorMessage: '家庭欠债原因{minLength} 到 {maxLength} 个字符',
							}, {
								validateFunction: (rule, value, data, callback) => {
									let reg = /^[\u4e00-\ue863a-z|A-Z|0-9（）(),，。.、]{1,200}$/
									if (reg.test(value)) {
										return true
									} else {
										callback('家庭欠债原因，不能含有特殊符号')
									}
								}
							}
						]
					},
					incomeType: {
						rules: [{
							required: true,
							errorMessage: '请勾选家庭主要收入来源'
						}]
					},
					comphone: {
						rules: [{
							required: true,
							errorMessage: '请填写请填村委(可区号)联系方式'
						}]
					},
					community: {
						rules: [{
							required: true,
							errorMessage: '请填写社区或村委的通信地址'
						}]
					},

					incomeOther: {
						rules: [{
							required: true,
							errorMessage: '请填写其他应当计入家庭的收入'
						}, {
							minLength: 1,
							maxLength: 50,
							errorMessage: '家庭其他应当计入家庭的收入描述{minLength} 到 {maxLength} 个字符',
						}, ]
					},
					yhzzInfo: {
						rules: [{
							minLength: 1,
							maxLength: 200,
							errorMessage: '填写已获资助的描述{minLength} 到 {maxLength} 个字符',
						}]
					},
				},
				huji: [{
					name: '农村户籍',
					checked: false,
					disabled: false,
					key: 'huji'
				}],
				typeList,
				incomeType: [{
					text: '无收入',
					value: 0,
				}, {
					text: '工资、奖金、津贴、补贴和其他劳动收入',
					value: 1,
				}, {
					text: '离退休金、基本养老金、基本生活费、失业保险金',
					value: 2,
				}, {
					text: '继承、接受赠予、出租或出售家庭财产获得的收入',
					value: 3,
				}, {
					text: '存款及利息，有价证券及红利、股票、博彩收入',
					value: 4,
				}, {
					text: '经商、办厂以及从事种植业、养植业、加工业扣除必要成本后的收入',
					value: 5,
				}, {
					text: '赡养费、抚(扶)养费',
					value: 6
				}, {
					text: '自谋职业收入',
					value: 7,
				}, {
					text: '其他应当计入家庭的收入',
					value: 8,
				}, ],
				//以下为弹窗选项
				parEp: [{
						text: '父母均没有工作（不含农村种植户或养殖户）',
						value: '父母均没有工作（不含农村种植户或养殖户）'
					}, {
						text: '父母一方没有工作（不含农村种植户或养殖户）',
						value: '父母一方没有工作（不含农村种植户或养殖户）'
					},
					{
						text: '农村个体小型种植户或个体小型养殖户（或两者均是）',
						value: '农村个体小型种植户或个体小型养殖户（或两者均是）'
					}
				],
				parCul: [{
					text: '父母均为初中及以下文化程度',
					value: '父母均为初中及以下文化程度'
				}, {
					text: '父母一方为初中及以下文化程度',
					value: '父母一方为初中及以下文化程度'
				}],
				parAge: [{
					text: '父母均为60周岁及以上',
					value: '父母均为60周岁及以上'
				}, {
					text: '父母一方为60周岁及以上',
					value: '父母一方为60周岁及以上'
				}],
				supportOp: [{
					text: '赡养人口数三位及以上（70周岁以上）',
					value: '赡养人口数三位及以上（70周岁以上）'
				}, {
					text: '赡养人口数两位及以下（70周岁以上）',
					value: '赡养人口数两位及以下（70周岁以上）'
				}],
				xuefeiOp: [{
					text: '学费、住宿费在9501元至20000元',
					value: '学费、住宿费在9501元至20000元'
				}, {
					text: '学费、住宿费在20001元以上',
					value: '学费、住宿费在20001元以上'
				}],
				familyHouseOp: [{
					text: '家庭住房自有',
					value: '家庭住房自有'
				}, {
					text: '家庭住房租赁',
					value: '家庭住房租赁'
				}],
				buyVehicleOp: [{
					text: '无车',
					value: 0
				}, {
					text: '小轿车',
					value: 1
				}, {
					text: '货车',
					value: 2
				}, {
					text: '农机车',
					value: 3
				}],
				learns: [{
					text: '2人（含本人）以上在上学',
					value: '2人（含本人）以上在上学'
				}, {
					text: '2人以下在上学',
					value: '2人以下在上学'
				}],
				logic: [{
					text: '是',
					value: '是',
				}, {
					text: '否',
					value: ''
				}],
				xsbrhj: [{
					text: '父母均患重大疾病（不含残疾）',
					value: '父母均患重大疾病（不含残疾）'
				}, {
					text: '父母一方患重大疾病（不含残疾）',
					value: '父母一方患重大疾病（不含残疾）'
				},
				{
					text: '其他家庭成员（含学生本人）患重大疾病',
					value: '其他家庭成员（含学生本人）患重大疾病'
				}],
				Dis: [{
					text: '一级残疾',
					value: '一级残疾'
				}, {
					text: '二级残疾',
					value: '二级残疾'
				}, {
					text: '三级残疾',
					value: '三级残疾'
				}, {
					text: '四级残疾',
					value: '四级残疾'
				}],
				// 重大意外
				zdywTime: [{
						text: '家庭遭重大突发意外事件（不含自然灾害）（一年内）',
						value: '家庭遭重大突发意外事件（不含自然灾害）（一年内）',
					},
					{
						text: '家庭遭重大突发意外事件（一年以上两年以内）',
						value: '家庭遭重大突发意外事件（一年以上两年以内）'
					}
				],
				//自然灾害
				zrzhTime: [{
					text: '家庭遭受重大自然灾害，受灾严重（一年内）',
					value: '家庭遭受重大自然灾害，受灾严重（一年内）'
				}, {
					text: '家庭遭受重大自然灾害，受灾严重（一年以上两年以内）',
					value: '家庭遭受重大自然灾害，受灾严重（一年以上两年以内）'
				}],
				time: [{
					text: '一年内',
					value: '一年内'
				}, {
					text: '一年以上两年以内',
					value: '一年以上两年以内'
				}],

			}
		},
		async onLoad(options) {
			that = this;
			vk = that.vk
			that.options = options

			getCatchInfo().then((data) => {
				let [err, res] = data
				if (res.data.code == 200) {
					if (res.data.data) {
						this.initData(res.data.data)
					}
				} else {
					vk.alert(res.data?.msg || err);
				}
			})



		},
		watch: {
			//监听欠债金额
			'formData.debt': function(newVal) {
				let logic = !!newVal
				if (this.debtRea == logic) {
					return
				}
				if (logic) {
					this.debtRea = true
				} else {
					this.formData.debtRea = ''
					this.debtRea = false
				}
			},

		},
		computed: {
			disabledChildren() {
				if (this.formData.facj == '是') {
					return true
				} else {

					return false
				}
			},
			naturalDisaster() {
				if (this.formData.naturalDisaster == '是') {
					return true
				} else {

					return false
				}
			},
			seriousIllness() {
				if (this.formData.seriousIllness == '是') {
					return true
				} else {

					return false
				}
			},
			suddenAccident() {
				if (this.formData.suddenAccident == '是') {
					return true
				} else {

					return false
				}
			}
		},
		methods: {
			initData(data) {
				let catchData = data
				this.formData = catchData
				setTimeout(() => {

					this.typeList = this.typeList.map((val) => {
						if (catchData[val.key]) {
							val.checked = true
							//禁用互斥选项
							if(val.mutex != undefined){
								val.mutex.forEach((e) => {
									this.typeList[e].disabled = true
									this.typeList[e].checked = false
								})
							}
						} else {
							val.checked = false
						}
						return val
					})
					if (catchData.nchj) {
						this.huji[0].checked = true
					} else {
						this.huji[0].checked = false
					}

					if (catchData.other) {
						this.other = true
					} else {
						this.other = false
					}
					// if (catchData.jtzs) {
					// 	this.jtzs = true
					// } else {
					// 	this.jtzs = false
					// }
					let onData = ['other', 'brcj', 'mocj', 'debtRea']

					onData.forEach((val) => {
						if (catchData[val]) {
							this[val] = true
						} else {
							this[val] = false
						}
					})

					// 初始化选项禁用状态
					this.formData.buyVehicle = this.formData.buyVehicle.split(',').map(Number)
					this.formData.incomeType = this.formData.incomeType.split(',').map(Number)
					this.buyVehicleChange()
					this.incomeTypeChange()
					this.checkboxChange
				})
			},
			submit() {


				uni.showLoading({
					title: '正在提交'
				})
				this.$refs.form.validate().then(res => {
					let form = JSON.parse(JSON.stringify(this.formData))

					this.typeList.forEach((item => {
						if (item.checked) {
							form[item.key] = '是'
						} else {
							form[item.key] = ''
						}
					}))
					if (this.huji[0].checked) {
						form.nchj = '是'
					} else {
						form.nchj = ''
					}
					form.other = this.formData.other

					form.buyVehicle = res.buyVehicle.join(',')
					form.incomeType = res.incomeType.join(',')



					addCatchInfo(form).then((data) => {
						uni.hideLoading()
						let [err, res] = data
						if (res.data.code == 200) {
							vk.setVuex('$app.catchData', form)

							vk.setVuex('$app.catchUpload', false)
							vk.toast(res.data.msg, "success", 800); // 修改时间延迟
							setTimeout(() => {
								vk.navigateBack();
							}, 810)
						} else {
							uni.showModal({
								title: '错误',
								content: res.data.msg || err
							})
						}
					})
				}).catch(err => {
					console.log(err)
					uni.showToast({
						icon: 'error',
						title: err[0].errorMessage
					})
					// uni.hideLoading()
				})
			},
			sl(e) {
				if (e.detail.value == '是') {
					this.seriousIllness = true
				} else {
					this.seriousIllness = false
				}
			},
			dc(e) {
				if (e.detail.value == '是') {

				} else {
					this.formData.faLevel = ''
					this.formData.faId = ''
					this.formData.faName = ''
				}
			},
			nd(e) {
				if (e.detail.value == '是') {

				} else {
					this.formData.naturalDisasterInfo = ''
					this.formData.naturalDisasterTime = ''
				}
			},
			sa(e) {
				if (e.detail.value == '是') {} else {

					this.formData.suddenAccidentInfo = ''
					this.formData.suddenAccidentTime = ''
				}
			},
			// 监听母亲是否残疾按钮
			mocjChange(e) {
				if (e.detail.value == '是') {
					this.mocj = true
				} else {
					this.mocj = false
					this.formData.moLevel = ''
					this.formData.moName = ''
					this.formData.moId - ''
				}
			},
			//监听欠债金额
			debtChange(e) {

			},
			// 监听家庭主要收入来源
			incomeTypeChange() {
				let value = this.formData.incomeType[0]
				console.log(value)
				//无收入时禁用其他选项
				if (value === undefined) {
					for (let i = 0; i <= 8; i++) {
						this.incomeType[i].disabled = false
					}

					this.incomeOther = false
					//重置其他收入，避免用户取消勾选，其他收入值继续上传
					this.formData.incomeOther = ''
					return
				}

				// 选中一个禁用其他
				for (let i = 0; i <= 8; i++) {
					if (value != i) {
						this.incomeType[i].disabled = true
					}
				}

				if (value == 8) {
					// console.log('选择其他')
					this.incomeOther = true
				}
			},
			// 监听购车情况
			buyVehicleChange() {
				let value = this.formData.buyVehicle[0]
				if (value == 0) {

					for (let i = 1; i <= 3; i++) {
						this.buyVehicleOp[i].disabled = true
					}
					this.formData.buyVehicle.splice(1, this.formData.buyVehicle.length - 1)

				} else {
					for (let i = 1; i <= 3; i++) {
						this.buyVehicleOp[i].disabled = false
					}
				}
			},
			nchjChange(e) {
				console.log(e)
			},
			//监听困难类型
			checkboxChange(e) {


				switch (e.name) {

					case '特困供养人员':
						this.typeList[5].mutex.forEach((val) => {
							if (e.value) {
								this.typeList[val].disabled = true
								this.typeList[val].checked = false
							} else {
								this.typeList[val].disabled = false
							}
						})

						break

					case '孤儿（事实无人抚养）':
						this.typeList[6].mutex.forEach((val) => {
							if (e.value) {
								this.typeList[val].disabled = true
								this.typeList[val].checked = false
							} else {
								this.typeList[val].disabled = false
							}
						})
						break
					case '特困职工子女':
						this.typeList[7].mutex.forEach((val) => {
							if (e.value) {
								this.typeList[val].disabled = true
								this.typeList[val].checked = false
							} else {
								this.typeList[val].disabled = false
							}
						})
						break
					case '最低生活保障户':
						this.typeList[8].mutex.forEach((val) => {
							if (e.value) {
								this.typeList[val].disabled = true
								this.typeList[val].checked = false
							} else {
								this.typeList[val].disabled = false
							}
						})

						break
					case '低保边缘、支出型困难家庭学生':
						this.typeList[9].mutex.forEach((val) => {
							if (e.value) {
								this.typeList[val].disabled = true
								this.typeList[val].checked = false
							} else {
								this.typeList[val].disabled = false
							}
						})

						break
					case '父母不能履行抚养义务的儿童':
						this.typeList[13].mutex.forEach((val) => {
							if (e.value) {
								this.typeList[val].disabled = true
								this.typeList[val].checked = false
							} else {
								this.typeList[val].disabled = false
							}
						})

						break
					case '父母一方抚养':
						this.typeList[12].mutex.forEach((val) => {
							if (e.value) {
								this.typeList[val].disabled = true
								this.typeList[val].checked = false
							} else {
								this.typeList[val].disabled = false
							}
						})

						break
					case '学生本人残疾':
						this.brcj = !this.brcj
						this.formData.stuLevel = ''
						break
					case '其他':
						this.other = !this.other
						this.formData.other = ''
						break

				}
			},
			// 选中任一checkbox时，由checkbox-group触发
			checkboxGroupChange(e) {
				// console.log(e);
			},
			// 全选
			checkedAll() {
				this.list.map(val => {
					val.checked = true;
				})
			},
			select(e) {
				uni.showLoading({
					title: '开始上传',
					mask: true
				})
			},
			progress(e) {
				uni.showLoading({
					title: '正在上传',
					mask: true
				})

			},
			success(e) {
				this.uploadOn = true
				uni.showToast({
					title: '上传成功,请点击提交,否则上传无效!'
				})
				uni.setStorage({
					key: 'file',
					data: this.file
				})
			},
			fail(e) {
				uni.showToast({
					title: '上传失败',
					icon: 'error'
				})
			},
			del(e) {
				vk.callFunction({
					url: 'client/catch/pub/deleteFile',
					title: '请求中...',
					data: {
						fileId: e.tempFilePath
					},
					success: function(data) {
						console.log(data)
						uni.removeStorage({
							key: 'file',
						})
					}
				});
			}
		}
	}
</script>

<style scoped>
	page {
		padding: 10rpx;
	}

	/deep/ uni-forms-item {
		font-size: 50px !important;
	}
</style>